<template>
    <div class="centermybox">
        <div class="my">
            <div class="mybox">
                <div class="myleft">
                    <img :src="my.tou" alt="">
                </div>
                <div class="myright">
                    <p>{{my.name}}&nbsp;</p>
                    <p><span>关注：{{my.gz}}</span><span>粉丝：{{my.fs}}</span></p>
                </div>
            </div>
        </div>
        <ul class="centerfive">
            <li v-for="item in centericon" :key="item.name">
                <svg class="icon" aria-hidden="true">
                    <use :xlink:href='item.icon'></use>
                </svg>
                <p>{{item.name}}</p>
            </li>
        </ul>
    </div> 
</template>
<script>
import { centericon } from '../other/other.js'
export default {
    name:"centermy",
    data(){
        return {
            id:0,
            centericon,
            my:{
                bgimg:'',
                tou:'',
                name:'',
                fs:0,
                gz:0
            }
        }
    },
    mounted(){
        if(localStorage.getItem("aboutmy") == null){
            this.getdata()
        }else{
            let obj = JSON.parse(localStorage.getItem("aboutmy"))
            this.my = obj
        }
    },
    methods:{
        getdata(){
            this.id = localStorage.getItem("_token")
            axios.get(`https://apis.netstart.cn/music/user/detail?uid=${this.id}&type=1`,{
                params:{

                }
            }).then(
                res=>{
                    // console.log(res)
                    // this.$emit("cs",{
                    //     show:true
                    // })
                    let data = res.data
                    this.my.bgimg = data.profile.backgroundUrl
                    this.my.tou = data.profile.avatarUrl
                    this.my.name = data.profile.nickname
                    this.my.fs = data.profile.followeds
                    this.my.gz = data.profile.follows
                    localStorage.setItem("aboutmy",JSON.stringify(this.my))
                },
                err=>{
                    console.log(err)
                }
            )
        }
    }
}
</script>
<style lang="less" scoped>
ul,li{
    margin: 0;
    padding: 0;
    list-style: none;
}
.centermybox{
    // background-color: violet;
    width: 100%;
    opacity: 1;
    .my{
        width: 100%;
        height: 250px;
        background-color: #78acf193;
        overflow: hidden;
        border-bottom-left-radius: 40%;
        border-bottom-right-radius: 40%;
    }
}
.mybox{
    display: flex;
    padding-top: 20%; 
    width: 80%;
    margin: 0 auto;
    .myleft{
        border-radius: 50%;
        overflow: hidden;
        width: 110px;
        height: 110px;
        text-align: center;
        background-color: #5893e2;
        img{
            width: 100px;
            margin-top: 5px;
            border-radius: 50%;
        }
    }
    .myright{
        margin-left: 20px;
        p{
            font-size: 1.2rem;
            span{
                display:inline-block;
                margin-right: 10px;
                font-size: 0.8rem;
            }
        }
    }
}
.centerfive{
    width: 80%;
    margin: 0 auto;
    margin-top:-40px;
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-radius: 10px;
    background-color: white;
    box-shadow: 3px 3px 10px #eee;
    text-align: center;
    li{
        svg{
            font-size: 1.7rem;
            color: #a3a3a3 ;
        }
        p{
            margin: 0;
            color:#a3a3a3 ;
            font-size: 0.9rem;
        }
    }
}
</style>